/**
 * pharma-model - 9 janv. 2011 guillaume
 */
package org.bspv.pharma.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.bspv.pharma.common.constant.Constants;

/**
 * @author guillaume
 */
@Entity
@Table(name = "_ORDER")
public class Order implements Serializable {

    /**
     * serialVersionUID.
     */
    private static final long serialVersionUID = 1L;

    /**
     * @author guillaume Enumération représentant l'état de la commande.
     */
    public static enum OrderStateEnum {
        /**
         * La commande est en cours de création.
         */
        ENCOURS,
        /**
         * La commande a été envoyée à la pharmacie.
         */
        ENVOYEE,
        /**
         * La commande est reçue partiellement.
         */
        PARTIELLE,
        /**
         * La commande est corrigée. (suite à une erreur)
         */
        CORRIGEE,
        /**
         * La commande est reçue (partiellement).
         */
        ENRECEPTION,
        /**
         * La commande est reçue complètement (ou a été corrigée).
         */
        TERMINEE,
        /**
         * La commande est annulée.
         */
        ANNULEE;
    }

    /**
     * Identifiant de la commande.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    /**
     * Pharmacie destinatrice de la commande.
     */
    @NotNull
    @ManyToOne
    private Drugstore drugstore;
    /**
     * Description de la commande.
     */
    @Size(max = Constants.CONSTRAINT_DESCRIPTION_SIZE)
    private String description;
    /**
     * Etat de la commande.
     */
    @NotNull
    @Enumerated(EnumType.STRING)
    private OrderStateEnum state;
    /**
     * Date de destruction(utilisation).
     */
    private Date destructionDate;
    /**
     * Document de commande.
     */
    @ManyToOne
    private Document document;
    /**
     * Commande corrigée.
     */
    @ManyToOne
    private Order correctedOrder;
    /**
     * Fin de mise en souffrance.
     */
    private Date outstandingEndDate;
    /**
     * Commentaire sur cette commande.
     */
    @Size(max = Constants.CONSTRAINT_COMMENT_SIZE)
    private String comment;
    /**
     * Numéro de version.
     */
    @Version
    private Integer version;

    /**
     * @return the id
     */
    public final Long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public final void setId(final Long id) {
        this.id = id;
    }

    /**
     * @return the drugstore
     */
    public final Drugstore getDrugstore() {
        return drugstore;
    }

    /**
     * @param drugstore
     *            the drugstore to set
     */
    public final void setDrugstore(final Drugstore drugstore) {
        this.drugstore = drugstore;
    }

    /**
     * @return the description
     */
    public final String getDescription() {
        return description;
    }

    /**
     * @param description
     *            the description to set
     */
    public final void setDescription(final String description) {
        this.description = description;
    }

    /**
     * @return the state
     */
    public final OrderStateEnum getState() {
        return state;
    }

    /**
     * @param state
     *            the state to set
     */
    public final void setState(final OrderStateEnum state) {
        this.state = state;
    }

    /**
     * @return the document
     */
    public final Document getDocument() {
        return document;
    }

    /**
     * @param document
     *            the document to set
     */
    public final void setDocument(final Document document) {
        this.document = document;
    }

    /**
     * @return the correctedOrder
     */
    public final Order getCorrectedOrder() {
        return correctedOrder;
    }

    /**
     * @param correctedOrder
     *            the correctedOrder to set
     */
    public final void setCorrectedOrder(final Order correctedOrder) {
        this.correctedOrder = correctedOrder;
    }

    /**
     * @return the outstandingEndDate
     */
    public final Date getOutstandingEndDate() {
        return outstandingEndDate;
    }

    /**
     * @param outstandingEndDate
     *            the outstandingEndDate to set
     */
    public final void setOutstandingEndDate(final Date outstandingEndDate) {
        this.outstandingEndDate = outstandingEndDate;
    }

    /**
     * @return the comment
     */
    public final String getComment() {
        return comment;
    }

    /**
     * @param comment
     *            the comment to set
     */
    public final void setComment(final String comment) {
        this.comment = comment;
    }

    /**
     * @return the version
     */
    public final Integer getVersion() {
        return version;
    }

    /**
     * @param version
     *            the version to set
     */
    public final void setVersion(final Integer version) {
        this.version = version;
    }

    /**
     * @return the destructionDate
     */
    public final Date getDestructionDate() {
        return destructionDate;
    }

    /**
     * @param destructionDate the destructionDate to set
     */
    public final void setDestructionDate(Date destructionDate) {
        this.destructionDate = destructionDate;
    }

}
